package com.example.service.impl;

import com.example.entity.Jiaoyi;
import com.example.mapper.JiaoyiMapper;
import com.example.service.IJiaoyiService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JiaoyiServiceImpl implements IJiaoyiService {
    @Autowired
    private JiaoyiMapper jiaoyiMapper;

    @Override
    public PageInfo<Jiaoyi> findAll(String name, Integer typeId, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);

        List<Jiaoyi> list = jiaoyiMapper.findAll(name,typeId);

        PageInfo<Jiaoyi> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }

    @Override
    public void delete(Integer id) {
        jiaoyiMapper.delete(id);
    }

    @Override
    public Jiaoyi getById(Integer id) {
        return jiaoyiMapper.getById(id);
    }

    @Override
    public void update(Jiaoyi jiaoyi) {
        jiaoyiMapper.update(jiaoyi);
    }
}
